<? 
require_once("../config/dbconn.php");require_once("../config/pagecls.php");
$sql="select * from {$db_prefix}users where id='".$_SESSION['sys_userid']."'";
$rs=$db->get_one($sql);
$db->free_result($result);
?>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">

<title>商城首页</title>
<link rel="stylesheet" type="text/css" href="css/footer.css"/>
<link rel="stylesheet" type="text/css" href="css/reset.css"/>
<link rel="stylesheet" type="text/css" href="css/header.css"/>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
		var infoUrl = '__APP__/Index/getSugessions';
		var goodsUrl = "__APP__/Details/details/";
</script>
<script type="text/javascript" src="js/header.js"></script>
<script type="text/javascript">
	$(function(){
		$('#top_header .item').hover(function(){
			$(this).addClass('hover');
		},function(){
			$(this).removeClass('hover');
		})

		$('#top_header .item .close').click(function(){
			$(this).parent().parent().removeClass('hover');
		})
		$('#nav_2014').on('mouseenter',function(){
			$('#nav_2014 .sub_nav').css('display','block');
		})
		$('#nav_2014').on('mouseleave',function(){
			$('#nav_2014 .sub_nav').css('display','none');
		})

		//搜索条件判断
		$("#jd_search").submit(function(){
			if($.trim($('#jd_search input').eq(0).val()) == ''){
				alert('搜索词不能为空~~');
				$('#jd_search input').eq(0).focus();
				return false;
			}
		})
	})
	
</script>
</head>
<body>
	<div id="top_nav">
		<div class="top_nav_con">
			<ul class="top_nav_r">
				<li>
					<span>您好！<span style="color:red;"><?=$rs['username']?></span>，欢迎来到电子商务平台！</span>
                    
					<a href="login.php"><?php 
						if($rs['username']==''){
							echo '[登录]';	
						}
					?></a>
                    <a href="login.php"><?php 
						if($rs['username']==''){
							echo '[免费注册]';	
						}
					?></a>
					<a ></a>
					<s class="separator"></s>
				</li>
			</ul>
		</div>
	</div>
	<div id="top_header">
		<div id="header">
			<div class="logo">
				<a href="product_buy.php"><img src="rs_files/logo.jpg" width="300px" height="85px"></a>
				<div>
				</div>
			</div>
			<div class="search">
				<div class="form">
<?
if ($act=='query'){
	$sqlf="select id,flname from {$db_prefix}psort where flname like '%$query%'";
		$rs1=$db->get_one($sqlf);
		/*var_dump($rs1);
		var_dump($rs1['id']);
		exit;*/
	$db->free_result($rs1);
	echo "<script>location.href='query_product.php?id={$rs1['id']}';</script>";exit();
}
/*if($act=='query' || $rs1['id']==''){
	$sqlf="select id,psortid from {$db_prefix}products where productname like '%$query%'";
		$rs1=$db->get_one($sqlf);
		var_dump($rs1);
		var_dump($rs1['id']);
		exit;
	$db->free_result($rs1);
	echo "<script>location.href='query_product.php?id={$rs1['id']}';</script>";exit();
}*/
?> 					<form action="?act=query" method="post" id="jd_search">
					<input class="keywords" type="text" name="query" value="<?=$query?>" />
					<input type="submit" class="button" value="搜索"/>
					</form>
				</div>
			</div>
			<div class="enterance">
				<ul>
					<li class="checkout">
						<span class="shopping">
							<span id="shopping-amount">
                            <?
				$j=0;
				$allprice=0;$allscprice=0;
				$goodcartstr=$_COOKIE['sys_goodscart'];
				if ($goodcartstr){
					$goodcartary=explode('|',$goodcartstr);
					foreach($goodcartary as $k1=>$v1){
						$j++;	
					}
				}?>
							
						</span>
						</span>
						<a href="index.php?action=buy">购物车(<?=$j;?>)去结算</a>
						<b></b>
					</li>
				</ul>
				<div class="jubao">
				</div>
			</div>
		</div>
		<div id="nav">
            <div class="nav0">
                <div id="nav_2014">
				<div id="cate_2014">
					<div class="mt">
						<h2>
						<a href="#">全部商品分类</a>
						<b></b>
						</h2>
					</div>
					<div class="sub_nav">
<?  
  $sql="select count(id) as c  from {$db_prefix}psort where  fid='0'"; 
  $rs2=$db->get_one($sql);  
  $sql="select * from {$db_prefix}psort where fid='0'";  
  $result1=$db->query($sql);
  while($rs2=$db->fetch_array($result1)){
?>
						<div class="item">
							<span>
								<h3>
									<a href="product_order_one.php?flname=<?=$rs2['flname']?>"><?=$rs2['flname']?></a>
								</h3>
								<s></s>
							</span>
							<div class="i_mc">
								<div class="close">X</div>
								<div class="subitem">
<?  
  $sql="select count(id) as c  from {$db_prefix}psort where  1"; 
  $rs3=$db->get_one($sql);  
  $sql="select * from {$db_prefix}psort where 1";  
  $result2=$db->query($sql);
  while($rs3=$db->fetch_array($result2)){ 
  	$str = $rs3['path'];
	$arr=(explode(',',$str,4));
	 if ($arr[0]==$rs2['id']) {
?>                                
									<dl class="fore1">
										<dt>
											<a href="product_order_one.php?flname=<?=$rs3['flname']?>"><?=$rs3['flname']?></a>
										</dt>
										<dd>
										</dd>
									</dl>
<? }}
	$db->free_result($result2);
?>                                    
								</div>
							</div>
						</div>
<? } 
	 $db->free_result($result1);
?>
					</div>
				</div>
			</div>         
			<ul id="navitems">
				<li><a href="product_buy.php">首页</a></li>
                <?  

 $sql="select * from {$db_prefix}psort where fid='0'";
  $sql.=" order by id asc limit 6";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
					<li>
						<a href="product_order_one.php?flname=<?=$rs['flname']?>"><?=$rs['flname']?>
						</a>
					</li>
  <?
  }
  $db->free_result($result);
  ?>           
				
			</ul>
        </div>
		</div>
	</div>
    
    
   